package com.rd.student.jiaji.class3.caiyuxin.Java8_1;

import java.util.Arrays;

public class Test2 {
    public static void main(String[] args) {
        int[] arr={1,2,3,4,5,6,7,8,9,10,11,12,13,14};
        rem(11,arr);

    }
    public static void rem(int n,int[] arr) {
        int count = -1;
        int[] newarr = new int[arr.length];
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == n) {
                count = i;
            }
        }
        if (count == -1) {
            System.out.println("未找到此元素");
        } else {
            for (int i = 0; i < count; i++) {
                newarr[i] = arr[i];
            }


            for (int i = count; i < arr.length - 1; i++) {
                newarr[i] = arr[i + 1];
            }
            newarr[arr.length - 1] = 0;

            System.out.println(Arrays.toString(newarr));

        }
    }
}
